package com.dgut.app.security;

import com.dgut.common.entity.WxUser;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.HashSet;

/**
 * @descrition:
 * @author: lzh
 */
@Data
public class WxUserDetails implements UserDetails {

    private String openid;

    private String username;

    private String password;

    private Collection<? extends GrantedAuthority> authorities;

    public WxUserDetails(){
        super();
    }

    public WxUserDetails(WxUser wxUser) {
        this.openid = wxUser.getOpenId();
        authorities = new HashSet<>();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
